package tt.dz.util;

/**
 * Created by luoyp on 2016/6/16.
 */
public class BinUtils
{
	public static String convertIntToReversedHexString(Integer source, int hexLength)
	{
		String hex = Integer.toString(source, 16);
		int length = hexLength;

		if (hex.length() < length)
		{
			int shortage = hexLength - hex.length();
			hex = String.format("%0" + shortage + "d", 0) + hex;
		}

		if (hex.length() % 2 == 1)
			hex = "0" + hex;

		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < hex.length(); i += 2)
		{
			sb.append(hex.substring(hex.length() - i - 2, hex.length() - i));
		}
		return sb.toString();
	}
}
